<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\imp\otd\otdapi\service;

class TaskCreateRequest {
	
	static $_TSPEC;
	public $taskId = null;
	public $taskCreateTime = null;
	public $vipBrandSn = null;
	public $taskStartTime = null;
	public $taskEndTime = null;
	public $advertiserId = null;
	public $platformType = null;
	public $relations = null;
	public $taskTitle = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'taskId'
			),
			2 => array(
			'var' => 'taskCreateTime'
			),
			3 => array(
			'var' => 'vipBrandSn'
			),
			4 => array(
			'var' => 'taskStartTime'
			),
			5 => array(
			'var' => 'taskEndTime'
			),
			6 => array(
			'var' => 'advertiserId'
			),
			7 => array(
			'var' => 'platformType'
			),
			8 => array(
			'var' => 'relations'
			),
			9 => array(
			'var' => 'taskTitle'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['taskId'])){
				
				$this->taskId = $vals['taskId'];
			}
			
			
			if (isset($vals['taskCreateTime'])){
				
				$this->taskCreateTime = $vals['taskCreateTime'];
			}
			
			
			if (isset($vals['vipBrandSn'])){
				
				$this->vipBrandSn = $vals['vipBrandSn'];
			}
			
			
			if (isset($vals['taskStartTime'])){
				
				$this->taskStartTime = $vals['taskStartTime'];
			}
			
			
			if (isset($vals['taskEndTime'])){
				
				$this->taskEndTime = $vals['taskEndTime'];
			}
			
			
			if (isset($vals['advertiserId'])){
				
				$this->advertiserId = $vals['advertiserId'];
			}
			
			
			if (isset($vals['platformType'])){
				
				$this->platformType = $vals['platformType'];
			}
			
			
			if (isset($vals['relations'])){
				
				$this->relations = $vals['relations'];
			}
			
			
			if (isset($vals['taskTitle'])){
				
				$this->taskTitle = $vals['taskTitle'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'TaskCreateRequest';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("taskId" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->taskId);
				
			}
			
			
			
			
			if ("taskCreateTime" == $schemeField){
				
				$needSkip = false;
				$input->readI64($this->taskCreateTime); 
				
			}
			
			
			
			
			if ("vipBrandSn" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->vipBrandSn);
				
			}
			
			
			
			
			if ("taskStartTime" == $schemeField){
				
				$needSkip = false;
				$input->readI64($this->taskStartTime); 
				
			}
			
			
			
			
			if ("taskEndTime" == $schemeField){
				
				$needSkip = false;
				$input->readI64($this->taskEndTime); 
				
			}
			
			
			
			
			if ("advertiserId" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->advertiserId);
				
			}
			
			
			
			
			if ("platformType" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->platformType);
				
			}
			
			
			
			
			if ("relations" == $schemeField){
				
				$needSkip = false;
				
				$this->relations = array();
				$_size0 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem0 = null;
						
						$elem0 = new \com\vip\imp\otd\otdapi\service\RelationData();
						$elem0->read($input);
						
						$this->relations[$_size0++] = $elem0;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("taskTitle" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->taskTitle);
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		if($this->taskId !== null) {
			
			$xfer += $output->writeFieldBegin('taskId');
			$xfer += $output->writeString($this->taskId);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldBegin('taskCreateTime');
		$xfer += $output->writeI64($this->taskCreateTime);
		
		$xfer += $output->writeFieldEnd();
		
		if($this->vipBrandSn !== null) {
			
			$xfer += $output->writeFieldBegin('vipBrandSn');
			$xfer += $output->writeString($this->vipBrandSn);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldBegin('taskStartTime');
		$xfer += $output->writeI64($this->taskStartTime);
		
		$xfer += $output->writeFieldEnd();
		
		$xfer += $output->writeFieldBegin('taskEndTime');
		$xfer += $output->writeI64($this->taskEndTime);
		
		$xfer += $output->writeFieldEnd();
		
		if($this->advertiserId !== null) {
			
			$xfer += $output->writeFieldBegin('advertiserId');
			$xfer += $output->writeString($this->advertiserId);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->platformType !== null) {
			
			$xfer += $output->writeFieldBegin('platformType');
			$xfer += $output->writeString($this->platformType);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->relations !== null) {
			
			$xfer += $output->writeFieldBegin('relations');
			
			if (!is_array($this->relations)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->relations as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->taskTitle !== null) {
			
			$xfer += $output->writeFieldBegin('taskTitle');
			$xfer += $output->writeString($this->taskTitle);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>